<template>
  <div>
    <van-search
      class="nav"
      v-model="value"
      shape="round"
      background="rgb(13, 255, 239)"
      placeholder="请输饿了么商家、商家名称"
      @click="sou"
    />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item>
        <ul class="box">
          <li v-for="item in list1" :key="item">
            <img :src="item.img" />
            {{ item.titl }}
          </li>
        </ul>
      </van-swipe-item>
      <van-swipe-item>
        <ul class="box">
          <li v-for="item in list2" :key="item">
            <img :src="item.img" />
            {{ item.titl }}
          </li>
        </ul>
      </van-swipe-item>
    </van-swipe>
    <van-card
      v-for="item in lists"
      :key="item.id"
      class="q1"
      :price="item.num"
      :desc="item.titl"
      :thumb="item.img"
    >
      <template #tags>
        <van-tag plain type="danger">{{ item.name }}</van-tag>
      </template>
      <template #footer>
        <van-button size="mini">加入购物车</van-button>
      </template>
    </van-card>
    <div class="w1"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: "",
      list: [],
      list1: [],
      list2: [],
      lists: [],
    };
  },
  mounted() {
    this.$axios.get("list.json").then((res) => {
      this.list = res.data.data;
      this.list1 = this.list.slice(0, 8);
      this.list2 = this.list.slice(8, 16);
    });
    this.$axios.get("lists.json").then((res) => {
      this.lists = res.data.data;
    });
  },
  methods: {
    sou(){
       this.$router.push({path:"/fa"})
    }
  },
};
</script>
<style  scoped>
* {
  list-style: none;
}
.nav {
  width: 100%;
  position: fixed;
  top: 0px;
  left: 0px;
  z-index: 9999;
}
.my-swipe .van-swipe-item {
  font-size: 20px;
  height: 180px;
  text-align: center;
  margin-top: 70px;
}
.box {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-around;
  align-items: space-around;
  flex-wrap: wrap;
}
.box li {
  width: 60px;
  height: 80px;
  margin-left: 30px;
  font-size: 10px;
}
.box li img {
  width: 100%;
  height: 60px;
}
.q1 {
  margin-top: 20px;
}
.w1 {
  margin-top: 80px;
}
</style>